/*
 * @description: 
 * @Date: 2022-11-24 19:18:42
 * @example: 
 * @params: 
 */
const express = require("express");
const fs = require("fs");
const app = express();
//引入路由模块
app.use(require("./login/login")); //登录模块
app.use(require("./uploads/index"));//文件上传模块
app.use(express.static("public")); // 配置静态资源
const port = 7878
// 设置允许跨域访问该服务
app.all("*", function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Headers", "Content-Type");
  res.header("Access-Control-Allow-Headers", "mytoken");
  next();
});
//端口
app.listen(port, () => console.log(`Example app listening on port ${port}`));
//测试接口
app.get("/", function (req, res) {
  fs.readFile("./index.html", function (err, font) {
    let str = font.toString("utf-8");
    console.log(str);
    res.send(str);
  });
});


